﻿using UnityEngine;

namespace ZSW.Framework.Utils
{
    public static class ZSWFUtil_Debug
    {
        public static void Log(string content)
        {
            Debug.Log(content);
        }

        public static void Log(string messageSource, string content)
        {
            Debug.Log(messageSource + ">>>" + content);
        }

        public static void Log<T>(string content)
        {
            Debug.Log(typeof(T).ToString() + ">>>" + content);
        }

        public static void LogWarning(string messageSource, string content)
        {
            Debug.LogWarning(messageSource + ">>>" + content);
        }

        public static void LogWarning<T>(string content)
        {
            Debug.LogWarning(typeof(T).ToString() + ">>>" + content);
        }

        public static void LogError(string messageSource, string content)
        {
            Debug.LogError(messageSource + ">>>" + content);
        }

        public static void LogError<T>(string content)
        {
            Debug.LogError(typeof(T).ToString() + ">>>" + content);
        }


        public static void Log(Vector2 content)
        {
            Log($"{convertVector2(content)}");
        }

        public static void Log(string messageSource, Vector2 content)
        {
            Log(messageSource, convertVector2(content));
        }

        public static void Log(Vector3 content)
        {
            Log($"{convertVector3(content)}");
        }

        public static void Log(string messageSource, Vector3 content)
        {
            Log(messageSource, convertVector3(content));
        }

        public static void Log(Quaternion quaternion)
        {
            Log($"{convertQuaternion(quaternion)}");
        }

        public static void Log(string messageSource, Quaternion quaternion)
        {
            Log(messageSource, convertQuaternion(quaternion));
        }

        public static void DrawLine(Vector3 start, Vector3 end, Color color, bool isExtend = false, float extendLength = 5)
        {
            Vector3 dir = Vector3.zero;
            if (isExtend)
            {
                dir = (end - start).normalized;
            }

            Debug.DrawLine(start - dir * extendLength, end + dir * extendLength, color);
        }

        private static string convertVector2(Vector2 vector)
        {
            return $"<color=red>x: {vector.x}</color> <color=green>y: {vector.y}</color>";
        }

        private static string convertVector3(Vector3 vector)
        {
            return
                $"<color=red>x: {vector.x}</color> <color=green>y: {vector.y}</color> <color=blue>z: {vector.z}</color>";
        }

        private static string convertQuaternion(Quaternion quaternion)
        {
            return
                $"<color=red>x: {quaternion.x}</color> <color=green>y: {quaternion.y}</color> <color=blue>z: {quaternion.z}</color> w: {quaternion.w}";
        }
    }
}